package com.enzoism.springboot.fastjson.define;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class WorkTimeValidated implements ConstraintValidator<WorkTime, Integer> {

    private int max;

    @Override
    public void initialize(WorkTime work) {
        max = work.max();
    }

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {
        Boolean flag = false;

        if (value == null || value < max) {
            flag = true;
        }

        return flag;
    }
}